package com.tarena.lbs.basic.web.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tarena.lbs.basic.web.mapper.UserTagsMapper;
import com.tarena.lbs.pojo.basic.po.UserTagsPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

//ServiceImpl是mybatis-plus提供的一个 持久层上层封装
//泛型1 就是对应这个业务下使用的mapper接口
//泛型2 对应这个mapper的po对象实体
@Repository
public class UserTagsRepository extends ServiceImpl<UserTagsMapper, UserTagsPO> {
    @Autowired
    private UserTagsMapper userTagsMapper;

    public void deleteByUserId(Integer id) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",id);
        userTagsMapper.delete(queryWrapper);
    }

    public List<UserTagsPO> getUserTags(Integer userId) {
        //select * from lbs_user_tags where user_id=#{}
        QueryWrapper<UserTagsPO> queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",userId);
        return userTagsMapper.selectList(queryWrapper);
    }
}
